/*Source

Problem Id:2698  User Id:Latex 
Memory:68K  Time:15MS
Language:G++  Result:Accepted

Source 
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>

	int drv[13];
	int seq[110];
	int nseq, ndrv;
	int in;
	int early[13];
	int inuse;
	int Ncase;
	int ct;
	

int in_drv(int a)
{
	int p;
	for (p=1; p<=inuse; p++)
		if (drv[p] == a) return true;
	return false;
}

int out_early()
{
	int i;
	
	printf("early : ");
	for (i=1; i<=ndrv; i++)
		printf("%ld ",early[i]);
	printf("\n");
	
	return 0;
}
	
int main()
{
	int i, j, k;
	
//	freopen("e.in", "r", stdin);
//	freopen("e.out", "w", stdout);
	
	scanf("%ld", &Ncase);
	for (ct=1; ct<=Ncase; ct++)
	{
		scanf("%ld%ld", &ndrv, &nseq);
		for (i=1; i<=nseq; i++)
			scanf("%ld", seq+i);
		
		inuse = 0;
		in = 0;
		for (i=1; i<=nseq; i++)
		{
			//debug
	//		printf("coming %ld\n", seq[i]);
			
			if (in_drv(seq[i])) 
			{
				//debug
				//printf("ingored\n");
				
				continue;
			}
			if (inuse < ndrv)
			{
				//debug
				//printf("insert to drv %ld\n", inuse+1);
				
				drv[++inuse] = seq[i];
				in++ ;
				continue;
			}
			memset(early, -1, sizeof(early));
			for (j=1; j<=ndrv; j++)
				for (k=i+1; k<=nseq; k++)
					if (seq[k] == drv[j])
					{
						early[j] = k;
						
						//debug
						//printf("seq[k] = %ld, drv[j] = %d, k = %ld\n",seq[k],drv[j],k);
						
						break;
					}
			k = 1;
			for (j=1; j<=inuse; j++)
				if (early[j] < early[k])
					k = j;
					
			if (early[k] == -1)
			{
				drv[k] = seq[i];
			} else
			{
				k = 1;
				for (j=1; j<=inuse; j++)
					if (early[j] > early[k])
						k = j;
				drv[k] = seq[i];
			}
			
			//debug
			//out_early();


			//debug 
			//	printf("replace %ld[%ld] with %ld\n", k, drv[k], seq[i]);
			
			in++;
		}
		printf("%ld\n", in);
	}
	return 0;
}


